#include<iostream>
#include<string>
#include<string.h>
using namespace std;

int main()
{
	int n, t1 = 1,t2 = 1;
	cin >> n;
	string a[100];
	for (int i = 0; i<n; i++)
	{
		cin >> a[i];
		if (i>0)
		{
			if (a[i] < a[i - 1])
				t1 = 0;
			if (a[i].size() < a[i - 1].size())
				t2 = 0;
		}

	}
	if (t1&&t2)
		cout << "both";
	else if (t1)
		cout << "lexicographically";
	else if (t2)
		cout << "lengths";
	else
		cout << "none";
}